#include <stdio.h>

int main()
{
    int a[10]={13,9,29,33,99,54,78,20,-20,7},i,l;
    int input;
    while(1) {
        int max_i=-1;
        scanf("%d",&input);
        if(input==0) {
            break;
        }
        scanf("%d",&l);
        for( i=0; i<10; i++) {
            if(a[i]<=l && (max_i==-1 || a[i]>a[max_i])) {
                max_i = i;
            }
        }
        if(max_i!=-1) {
            printf("%d\n",a[max_i]);
        }
    }
    return 0;
}